package com.qd.common.panda.domain.entity.wallet.publish;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 发布套餐
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class PlanPublishDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "套餐发布ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "套餐发布ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String publishId;
    /**
     * 标题
     */
    @Size(max = 100, message = "标题长度不能超过{max}位", groups = DefaultGroup.class)
    private String title;
    /**
     * 开始日期
     */
    private String startDate;
    /**
     * 结束日期
     */
    private String endDate;
    /**
     * 添加时间
     */
    private LocalDateTime addTime;
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    /**
     * 是否启用
     */
    @Size(max = 50, message = "是否启用长度不能超过{max}位", groups = DefaultGroup.class)
    private String enable;
    /**
     * 是否启用显示
     */
    private String enableDisplay;
    /**
     * 操作人
     */
    @Size(max = 50, message = "操作人长度不能超过{max}位", groups = DefaultGroup.class)
    private String operator;
    /**
     * 操作人显示
     */
    private String operatorDisplay;
    /**
     * 操作组织
     */
    @Size(max = 50, message = "操作组织长度不能超过{max}位", groups = DefaultGroup.class)
    private String operateOrgId;
    /**
     * 操作组织显示
     */
    private String operateOrgIdDisplay;
    /**
     * 套餐列表
     */
    private List<PlanPublishListDTO> planPublishList;

    @Override
    public void freeData() {
        this.publishId = null;
        this.title = null;
        this.startDate = null;
        this.endDate = null;
        this.addTime = null;
        this.updateTime = null;
        this.enable = null;
        this.enableDisplay= null;
        this.operator = null;
        this.operatorDisplay = null;
        this.operateOrgId = null;
        this.operateOrgIdDisplay = null;
        Optional.ofNullable(planPublishList).ifPresent(List::clear);
        super.freeData();
    }
}
